import axios from 'axios';

//分页列表
const URI_DATAGRID = "/filemanager/api/filemanager/file/datagrid";
//删除
const URI_REMOVE = "/filemanager/api/filemanager/file/remove";
//添加
const URI_ADD_SUBMIT = "/filemanager/api/filemanager/file/add";
//更新
const URI_UPDATE_SUBMIT = "/filemanager/api/filemanager/file/edit";

export const datagrid = (params, callback = function(res) {}) => {
	axios.post(URI_DATAGRID, params).then((response) => {
		callback(response.data);
	});
}

export const remove = (ids, callback = function(res) {}) => {
	axios.post(URI_REMOVE, {ids}).then((response) => {
		callback(response.data);
	});
}

export const add = (value, callback = function(res) {}) => {
	axios.post(URI_ADD_SUBMIT, value, {
		headers: {
			"Content-Type": "multipart/form-data"
		}
	}).then((response) => {
		callback(response.data);
	});
}

export const update = (value, callback = function(res) {}) => {
	axios.post(URI_UPDATE_SUBMIT, value).then((response) => {
		callback(response.data);
	});
}

export default {
	datagrid,
	remove,
	add,
	update
}